#include "DlmInfoListener.h"
#include "Info.h"
#include "../LoggerModule/Logger.h"
#include <sys/param.h>

#include <unistd.h>

DlmInfoListener::DlmInfoListener(int info_fd) :
	infoFd_(info_fd)
{}
		
void DlmInfoListener::listen()
{
	struct InfoHeader ih;
	char buffer[PIPE_BUF - sizeof(struct InfoHeader)];
	
	while(1)
	{
		read(infoFd_, &ih, sizeof(ih));
		read(infoFd_, &buffer, ih.msgLen);
		
		Logger::getInstance().logProcess(ih.pid, buffer);
	}
}

